package com.danco.training.zaneuskaya.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * @author Zaneuskaya Aliaksandra
 *
 */
@Entity
@Table(name = "job")
public class Job implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5236593662432562643L;

	@Id
	@GeneratedValue
	@Column(name = "job_id")
	private Integer jobId;

	@Column(name = "job_start")
	@Temporal(value = TemporalType.DATE)
	private Date jobStartDate;

	@Column(name = "job_end")
	@Temporal(value = TemporalType.DATE)
	private Date jobEndDate;

	@Column(name = "position")
	private String position;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "country_fk", referencedColumnName = "country_id")
	private Country jobCountry;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "city_fk", referencedColumnName = "city_id")
	private City jobCity;

	@Column(name = "company_title")
	private String companyTitle;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_fk", referencedColumnName = "user_id")
	private User userJob;

	public Integer getJobId() {
		return jobId;
	}

	public void setJobId(Integer jobId) {
		this.jobId = jobId;
	}

	public Date getJobStartDate() {
		return jobStartDate;
	}

	public void setJobStartDate(Date jobStartDate) {
		this.jobStartDate = jobStartDate;
	}

	public Date getJobEndDate() {
		return jobEndDate;
	}

	public void setJobEndDate(Date jobEndDate) {
		this.jobEndDate = jobEndDate;
	}

	public String getPosition() {
		return position;
	}

	public void setPosition(String position) {
		this.position = position;
	}

	public Country getJobCountry() {
		return jobCountry;
	}

	public void setJobCountry(Country jobCountry) {
		this.jobCountry = jobCountry;
	}

	public City getJobCity() {
		return jobCity;
	}

	public void setJobCity(City jobCity) {
		this.jobCity = jobCity;
	}

	public String getCompanyTitle() {
		return companyTitle;
	}

	public void setCompanyTitle(String companyTitle) {
		this.companyTitle = companyTitle;
	}

	public User getUserJob() {
		return userJob;
	}

	public void setUserJob(User userJob) {
		this.userJob = userJob;
	}

	@Override
	public int hashCode() {
		return getJobId();
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Job) {
			Job other = (Job) obj;
			return other.getJobId() == jobId;
		}
		return false;
	}

}
